package com.gomore.opple.data.remote.retrofit.interceptor;

import com.gomore.opple.OppleApplication;
import com.gomore.opple.utils.DeviceUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Company 上海勾芒科技有限公司.
 * Email 753147900@qq.com
 */
public class HeadInterceptor implements Interceptor {
    public HeadInterceptor() {
        super();
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder requestBuilder = chain.request().newBuilder();
        requestBuilder.addHeader("Content-Type", "application/json;charset=utf-8");
        requestBuilder.addHeader("Accept", "application/json;charset=utf-8");
        requestBuilder.addHeader("Version", DeviceUtils.getVersionName(OppleApplication.getInstance()));
        requestBuilder.addHeader("Device", DeviceUtils.getDeviceName(OppleApplication.getInstance()));
        requestBuilder.addHeader("DeviceVersion", DeviceUtils.getDeviceId(OppleApplication.getInstance()));
        Request request = requestBuilder.build();
        return chain.proceed(request);
    }
}
